package cn.com.xf.dao.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.com.xf.dao.TblOaAuthPermissionDAO;
import cn.com.xf.dao.support.XFSqlMapClientDaoSupport;
import cn.com.xf.domain.TblOaAuthPermission;

@Repository
public class TblOaAuthPermissionDAOImpl extends XFSqlMapClientDaoSupport implements TblOaAuthPermissionDAO {

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	public TblOaAuthPermissionDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public int deleteByPrimaryKey(BigDecimal permissionId) {
		TblOaAuthPermission key = new TblOaAuthPermission();
		key.setPermissionId(permissionId);
		int rows = getSqlMapClientTemplate().delete("TBL_OA_AUTH_PERMISSION.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public void insert(TblOaAuthPermission record) {
		getSqlMapClientTemplate().insert("TBL_OA_AUTH_PERMISSION.ibatorgenerated_insert", record);
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public void insertSelective(TblOaAuthPermission record) {
		getSqlMapClientTemplate().insert("TBL_OA_AUTH_PERMISSION.ibatorgenerated_insertSelective", record);
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public TblOaAuthPermission selectByPrimaryKey(BigDecimal permissionId) {
		TblOaAuthPermission key = new TblOaAuthPermission();
		key.setPermissionId(permissionId);
		TblOaAuthPermission record = (TblOaAuthPermission) getSqlMapClientTemplate().queryForObject(
				"TBL_OA_AUTH_PERMISSION.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public int updateByPrimaryKeySelective(TblOaAuthPermission record) {
		int rows = getSqlMapClientTemplate().update(
				"TBL_OA_AUTH_PERMISSION.ibatorgenerated_updateByPrimaryKeySelective", record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method
	 * corresponds to the database table TBL_OA_AUTH_PERMISSION
	 * 
	 * @ibatorgenerated Mon Jun 15 10:38:48 GMT+08:00 2015
	 */
	@Override
	public int updateByPrimaryKey(TblOaAuthPermission record) {
		int rows = getSqlMapClientTemplate()
				.update("TBL_OA_AUTH_PERMISSION.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	@Override
	public List<TblOaAuthPermission> selectAllPermission() {
		return getSqlMapClientTemplate().queryForList("TBL_OA_AUTH_PERMISSION.ibatorgenerated_selectAllPermission");
	}

	@Override
	public List<TblOaAuthPermission> selectByRoleIds(List<String> roleIds) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("roleIds", roleIds);
		ArrayList<TblOaAuthPermission> list = (ArrayList<TblOaAuthPermission>) getSqlMapClientTemplate().queryForList(
				"TBL_OA_AUTH_PERMISSION.ibatorgenerated_selectByRoleIds", map);
		return list;
	}

	@Override
	public List<TblOaAuthPermission> selectAllPermission4Check() {
		return getSqlMapClientTemplate().queryForList(
				"TBL_OA_AUTH_PERMISSION.ibatorgenerated_selectAllPermission4Check");
	}
}